import {ChangeDetectorRef, Component} from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {JidihttpProvider} from "../../providers/jidihttp/jidihttp";
import {DomSanitizer} from "@angular/platform-browser";

/**
 * Generated class for the HuodonginfoPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */
@Component({
  selector: 'page-huodonginfo',
  templateUrl: 'huodonginfo.html',
})
export class HuodonginfoPage {
  huodongid:string;
  huodong_type_image:string;
  huodong_name:string;
  chuangjian_time:string;
  huodong_image:string;
  huodong_content:string;
  huodong_start:string;
  huodong_end:string;

  //type;
  houdongType:string;
  constructor(public sanitizer:DomSanitizer,public navCtrl: NavController, public navParams: NavParams,public cdchange:ChangeDetectorRef,public jidiProvider:JidihttpProvider) {
    this.huodongid=this.navParams.get('uuid')
    this.jidihttpInfoClinet(this.huodongid);
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad HuodonginfoPage');
  }

  /** 网络请求 **/
  jidihttpInfoClinet(uuid){
    this.jidiProvider.getHuodongInfoHttp(uuid).subscribe(data => {


      this.houdongType = data["activityState"]+"";
      if("-1"==this.houdongType){
        this.huodong_type_image="assets/imgs/huodongjieshu.png";
      }else{
        this.huodong_type_image="assets/imgs/huodongkaishi.png";
      }


      this.huodong_start = data['data']["beginTime"];
      this.huodong_content = data['data']["content"];
      this.chuangjian_time = data['data']["createTime"];
      this.huodong_end = data['data']["endTime"];
      this.huodong_image = data['data']["img"];
      this.huodong_name = data['data']["title"];
      this.cdchange.detectChanges();
    },error => {

    });

  }
  assembleHTML(strHTML:any){
    return this.sanitizer.bypassSecurityTrustHtml(strHTML);
  }
}
